<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head >
	<th:block th:include="include :: header" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-contractInfo-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">合同编号：</label>
				<div class="col-sm-8">
					<input id="contractNum" name="contractNum" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">合同名称：</label>
				<div class="col-sm-8">
					<input id="contractName" name="contractName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">签订地点：</label>
				<div class="col-sm-8">
					<input id="signPlace" name="signPlace" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">签订单位：</label>
				<div class="col-sm-8">
					<input id="signUnit" name="signUnit" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">合同负责人：</label>
				<div class="col-sm-8">
					<input id="contractPrincipal" name="contractPrincipal" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">联系方式：</label>
				<div class="col-sm-8">
					<input id="linkWay" name="linkWay" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">签订日期：</label>
				<div class="col-sm-8">
					<div class="input-group date">
						<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
						<input id="signDate" name="signDate" type="text" class="form-control" placeholder="yyyy-MM-dd" required>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">到期日期：</label>
				<div class="col-sm-8">
					<div class="input-group date">
						<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
						<input id="maturityDate" name="maturityDate" type="text" class="form-control" placeholder="yyyy-MM-dd" required>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">合同金额：</label>
				<div class="col-sm-8">
					<input id="contractAmount" name="contractAmount" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">合同上传：</label>
				<div class="col-sm-8">
					<input id="contractAttachment" name="contractAttachment" class="form-control" type="hidden">
					<div class="file-loading">
						<input id="fileinput-upload" type="file" multiple name="file">
					</div>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
	<th:block th:include="include :: bootstrap-fileinput-js" />
    <script type="text/javascript">
		var prefix = ctx + "business/contractInfo"
		$("#form-contractInfo-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});

		$(function () {
			//bootstrap-fileinput
			$("#fileinput-upload").fileinput({
				language: 'zh',
				'theme': 'explorer-fas',
				'uploadUrl': ctx + 'business/attachment/uploadMore',
				uploadAsync:false,//false 同步上传，后台用数组接收，true 异步上传，每次上传一个file,会调用多次接口
				overwriteInitial: false,
				initialPreviewAsData: true,
				allowedFileExtensions : ['doc','docx','pdf','PDF',"xls", "xlsx","exe","bmp", "gif", "jpg", "jpeg", "png",
					"ppt", "pptx", "html", "htm", "txt","rar", "zip", "mp3","mp4","MPEG","MP3\MPEG-4","MIDI","WMA"],//接收的文件后缀
				showPreview: true,
				showUpload: true, //是否显示上传按钮
				showCaption: true,//是否显示标题
				maxFileCount: 5, //表示允许同时上传的最大文件个数
				maxFileSize: 200000
			}).on("filebatchuploadsuccess", function(event, data) {
				console.log(data.response.url);
				$("#contractAttachment").val(data.response.url);
			});

			/* 日期控件 */
			layui.use('laydate', function() {
				var laydate = layui.laydate;
				laydate.render({
					elem: '#signDate',
					type: 'date'
				});
				laydate.render({
					elem: '#maturityDate',
					type: 'date'
				});
			});
		});

		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-contractInfo-add').serialize());
	        }
	    }
	</script>
</body>
</html>
